home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / fpu881 / src6.zoo / acosh.c < prev    next >
C/C++ Source or Header  |  1991-09-24  |  3KB  |  112 lines

  1. /************************************************************************
  2.  *                                    *
  3.  *                N O T I C E                *
  4.  *                                    *
  5.  *            Copyright Abandoned, 1987, Fred Fish        *
  6.  *                                    *
  7.  *    This previously copyrighted work has been placed into the    *
  8.  *    public domain by the author (Fred Fish) and may be freely used    *
  9.  *    for any purpose, private or commercial.  I would appreciate    *
  10.  *    it, as a courtesy, if this notice is left in all copies and    *
  11.  *    derivative works.  Thank you, and enjoy...            *
  12.  *                                    *
  13.  *    The author makes no warranty of any kind with respect to this    *
  14.  *    product and explicitly disclaims any implied warranties of    *
  15.  *    merchantability or fitness for any particular purpose.        *
  16.  *                                    *
  17.  ************************************************************************
  18.  */
  19.  
  20.  
  21. /*
  22.  *  FUNCTION
  23.  *
  24.  *    acosh   double precision hyperbolic arc cosine
  25.  *
  26.  *  KEY WORDS
  27.  *
  28.  *    acosh
  29.  *    machine independent routines
  30.  *    math libraries
  31.  *
  32.  *  DESCRIPTION
  33.  *
  34.  *    Returns double precision hyperbolic arc cosine of double precision
  35.  *    floating point number.
  36.  *
  37.  *  USAGE
  38.  *
  39.  *    double acosh (x)
  40.  *    double x;
  41.  *
  42.  *  RESTRICTIONS
  43.  *
  44.  *    The range of the ACOSH function is all real numbers greater
  45.  *    than or equal to 1.0 however large arguments may cause
  46.  *    overflow in the x squared portion of the function evaluation.
  47.  *
  48.  *    For precision information refer to documentation of the
  49.  *    floating point library primatives called.
  50.  *    
  51.  *  PROGRAMMER
  52.  *
  53.  *    Fred Fish
  54.  *
  55.  *  INTERNALS
  56.  *
  57.  *    Computes acosh(x) from:
  58.  *
  59.  *        1.    If x < 1.0 then report illegal
  60.  *            argument and return zero.
  61.  *
  62.  *        2.    If x > sqrt(MAXDOUBLE) then
  63.  *            set x = sqrt(MAXDOUBLE and
  64.  *            continue after reporting overflow.
  65.  *
  66.  *        3.    acosh(x) = log [x+sqrt(x**2 - 1)]
  67.  *
  68.  */
  69.  
  70. #include <stdio.h>
  71. #include <pmluser.h>
  72. #include "pml.h"
  73.  
  74. static char funcname[] = "acosh";
  75.  
  76.  
  77. double acosh (x)
  78. double x;
  79. {
  80.     auto struct exception xcpt;
  81.     extern double log ();
  82.     extern double sqrt ();
  83.  
  84.     DBUG_ENTER (funcname);
  85.     DBUG_3 ("acoshin", "arg %le", x);
  86.     if (x < 1.0) {
  87.     xcpt.type = DOMAIN;
  88.     xcpt.name = funcname;
  89.     xcpt.arg1 = x;
  90.     if (!matherr (&xcpt)) {
  91.         fprintf (stderr, "%s: DOMAIN error\n", funcname);
  92.         errno = ERANGE;
  93.         xcpt.retval = 0.0;
  94.     }
  95.     } else if (x > SQRT_MAXDOUBLE) {
  96.     xcpt.type = OVERFLOW;
  97.     xcpt.name = funcname;
  98.     xcpt.arg1 = x;
  99.     if (!matherr (&xcpt)) {
  100.         fprintf (stderr, "%s: OVERFLOW error\n", funcname);
  101.         errno = ERANGE;
  102.         x = SQRT_MAXDOUBLE;
  103.         xcpt.retval = log (2* SQRT_MAXDOUBLE);
  104.     }
  105.     } else {
  106.     xcpt.retval = log (x + sqrt (x*x - 1.0));
  107.     }
  108.     DBUG_3 ("acoshout", "result %le", xcpt.retval);
  109.     DBUG_RETURN (xcpt.retval);
  110. }
  111.  
  112.